/*
函数式编程：变换
原始集合没被修改， 新的集合会修改，这样变量就不会变来变去*/
fun main() {
    val animals = listOf("zebra", "giraffe", "elephant", "rat")
    val babies = animals
        .map { animal -> "A baby $animal"}
        .map { baby -> "$baby,with the cutest little tail ever!" }
    println(animals)
    println(babies)

    val animalsLength = animals.map { it.length }
    println(animalsLength)

/*[zebra, giraffe, elephant, rat]
[A baby zebra,with the cutest little tail ever!, A baby giraffe,with the cutest little tail ever!, A baby elephant,with the cutest little tail ever!, A baby rat,with the cutest little tail ever!]
[5, 7, 8, 3]
*/
}